<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script language="javascript" type="text/javascript"
        src="js/datepicker/My97DatePicker/WdatePicker.js"></script>
        <title>Manage Center</title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <%@ page import="java.util.List"%>
        <%@ page import="model.MovieSection"%>

        <div id="container">
            <jsp:include page="../includes/header.html" />
            <div class="main">
                <div class="services">
                    <div class="service_bg">
                        <h3>Manager Center</h3>
                        <ul class="link">
                            <li>You can search, update, delete or add movies sections on page <a href="movieManagement.do"><strong>Movie Management</strong></a>.</li>
                            <li>You can search, delete or add officers on page <a href="OfficerManagement.do"><strong>Officer Management</strong></a>.</li>
                            <li>You can manage all sections' seats on page <a href="manageSeat.do"><strong>Manage Seats</strong></a></li>
                            <li>If you want to view the statistic of movies and houses, please go to <a href="managerReport.do"><strong>Statistic</strong></a></li>
                            <li>If you want to log out, please <a href="logout.do"><strong>log out</strong></a>.</li>
                        </ul>
                        <div class="clr"></div>
                        <div class="service_bg">
                            <h3>About the authors</h3>
                            <p><img src="images/user_pic.jpg" width="63" height="63" hspace="5" align="left" alt="picture" /><a href="#"><strong>ZHANG Niantong</strong></a><br />
                                Department of Computer Science, City University of Hong Kong</p>
                            <p><img src="images/user_pic.jpg" width="63" height="63" hspace="5" align="left" alt="picture" /><a href="#"><strong>ZHANG Hao</strong></a><br />
                                Department of Computer Science, City University of Hong Kong</p>
                        </div></div>
                    <div class="clr"></div>
                </div>
                <div class="global_main">
                    <div class="page_title_text">
                        <h1>Movie Management</h1>
                    </div>
                    <div class="clr"></div>
                    <div class="Mt">
                        <div class="title">
                            <h3>Search Movie</h3>
                        </div>
                        <div class="clr"></div>
                        <%
                                    request.setAttribute("searchFormAction", "movieManagement.do");
                        %>
                        <jsp:include page="../../searchMovieIncludes/searchForm.jsp" />
                    </div>
                    <br/>
                    <br/>
                    <%
                                if (session.getAttribute("listMovieSection") != null) {
                    %>
                    <br/><br/>
                    <div id="movieT" class="Mt">
                        <div class="title">
                            <h3>Search Result</h3>
                        </div>
                        <div class="clr"></div>
                        <table id="movieTable">
                            <thead>
                                <tr>
                                    <th>Name</th>
                                    <th>Price</th>
                                    <th>Start Time</th>
                                    <th>Duration</th>
                                    <th>House</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <%
                                                                    if (session.getAttribute("listMovieSection") != null) {
                                                                        List<MovieSection> listMovieSection = (List<MovieSection>) session.getAttribute("listMovieSection");
                                                                        session.setAttribute("listMovieSection", null);
                                                                        for (MovieSection movieSection : listMovieSection) {
                                                                            pageContext.setAttribute("curr_movieSection", movieSection);
                                %>
                                <tr>
                                    <td>${curr_movieSection.movieName}</td>
                                    <td>${curr_movieSection.price}</td>
                                    <td>${curr_movieSection.startTimeString}</td>
                                    <td>${curr_movieSection.duration}</td>
                                    <td>${curr_movieSection.houseId}</td>
                                    <td><a
                                            href="movieManagement.do?action=update&id=${curr_movieSection.id}">Update</a>
                                        <a
                                            href="movieManagement.do?action=delete&id=${curr_movieSection.id}">Delete</a>
                                    </td>
                                </tr>
                                <%
                                                                        }
                                                                    }
                                %>
                            </tbody>
                        </table>

                    </div>
                    <%
                                }
                    %>
                    <div class="Mt">
                        <br/> <br/>
                        <div class="title">
                            <h3>Add Movie</h3>
                        </div>
                        <div class="clr"></div>
                        <form action="movieManagement.do" method="post" class="movieform">
                            <input name="action" type="hidden" value="create" />
                            <div>
                                <label>Movie Name:</label>
                                <input type="text" name="movieName" />
                            </div>
                            <div>
                                <label>Price: </label>
                                <input type="text" name="price" />
                            </div>
                            <label>Date: </label>
                            <input type="text" id="d233" name="startTime" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})" />
                            <div>
                                <label>Duration: </label> <input type="text" name="duration" />
                            </div>
                            <div>
                                <label>House Id:</label>
                                <select name="houseId">
                                    <%
                                                List<String> listHouseId = (List<String>) session.getAttribute("listHouseId");
                                                for (String houseId : listHouseId) {
                                    %>
                                    <option value ="<%=houseId%>"><%=houseId%></option>
                                    <%
                                                }
                                    %>
                                </select>
                            </div>
                            <div class="button">
                                <input type="submit" value="Create" />
                                <input type="reset" value="Reset" />
                            </div>
                        </form>
                    </div>
                </div>
                <div class="clr"></div>
            </div>
            <jsp:include page="../includes/footer.html" />
        </div>
    </body>
</html>